package com.sjtu.vfact.visualization.util;

import com.sjtu.vfact.visualization.base.VfactEdge;
import com.sjtu.vfact.visualization.base.VfactVertex;
import com.sjtu.vfact.visualization.view.GraphFrame;

import edu.uci.ics.jung.algorithms.layout.CircleLayout;
import edu.uci.ics.jung.algorithms.layout.FRLayout;
import edu.uci.ics.jung.algorithms.layout.FRLayout2;
import edu.uci.ics.jung.algorithms.layout.KKLayout;
import edu.uci.ics.jung.algorithms.layout.Layout;
import edu.uci.ics.jung.algorithms.layout.SpringLayout;
import edu.uci.ics.jung.algorithms.layout.SpringLayout2;
import edu.uci.ics.jung.graph.Graph;

public class VizUtil {
	
	public static Layout<VfactVertex, VfactEdge> createLayoutByName(String name, Graph<VfactVertex, VfactEdge> graph){
		if(name.equals(GraphFrame.FR)){
			return new FRLayout<VfactVertex, VfactEdge>(graph);
		}else if(name.equals(GraphFrame.FR2)){
			return new FRLayout2<VfactVertex, VfactEdge>(graph);
		}else if(name.equals(GraphFrame.CIRCLE)){
			return new CircleLayout<VfactVertex, VfactEdge>(graph);
		}else if(name.equals(GraphFrame.KK)){
			return new KKLayout<VfactVertex, VfactEdge>(graph);
		}else if(name.equals(GraphFrame.SPRING)){
			return new SpringLayout<VfactVertex, VfactEdge>(graph);
		}else if(name.equals(GraphFrame.SPRING2)){
			return new SpringLayout2<VfactVertex, VfactEdge>(graph);
		}else{
			System.err.println("Inalid Layout Name : No known Layout for the name : " + name);
			return null;
		}
	}

}
